<template>
  <div>
    <t-dialog :visible.sync="info.visible" header="汇总列表" :confirmBtn="null" :onConfirm="onConfirm" width="90%" :onClose="onConfirm" top="5%">
      <t-table
        rowKey="index"
        :data="data"
        :columns="columns"
        style="height: 50vh"
      >
        <template  #dealOpinion="{ row }">
          <t-tag :theme="handleTheme(row.dealOpinion,dict.type.deal_opinion)" variant="light">
            {{row.dealOpinion | filterByDict(dict.type.deal_opinion)}}
          </t-tag>
        </template>
        <template  #summary="{ row }">
          <t-tag v-if="row.summary==='1'" theme="success"  variant="light">已汇总</t-tag>
          <t-tag v-else theme="default"  variant="light">未汇总</t-tag>
        </template>
      </t-table>
    </t-dialog>


  </div>

</template>

<script>

export default {
  name: "opinion-info",
  dicts:["deal_opinion"],
  props:{
    info:{
      type:Object,
      default(){
        return{
          id:"",
          header:"",
          visible:false,
          type:"yk"
        }
      }
    }
  },
  data(){
    return{
      summaryForm:false,
      summaryShow:false,
      rules: {
        dealOpinion: [
          {
            required: true,
            message: "处理意见不能为空",
          },
        ],
        note: [
          {
            required: true,
            message: "备注不能为空",
          },
        ],
        summary: [
          {
            required: true,
            message: "汇总不能为空",
          },
        ],

      },
      formData:{
        dealOpinion:"",
        note:"",
        summary:"0"
      },
      nowRow:{},
      columns1: [
        {
          colKey: 'chapterNum',
          title: '地方标准章条编号',
          align:"center"

        },
        {
          colKey: 'opinion',
          title: '意见内容',
          align:"center"
        },
        {
          colKey: 'personName',
          title: '提出人',
          align:"center"
        },
        {
          colKey: 'deptName',
          title: '提出单位',
          align:"center"
        },
        {
          colKey: 'summary',
          title: '汇总状态',
          align:"center"
        },
      ],
      columns2: [
        {
          colKey: 'chapterNum',
          title: '地方标准章条编号',
          align:"center"

        },
        {
          colKey: 'opinion',
          title: '意见内容',
          align:"center"
        },
        {
          colKey: 'personName',
          title: '提出人',
          align:"center"
        },
        {
          colKey: 'deptName',
          title: '提出单位',
          align:"center"
        },
        {
          colKey: 'note',
          title: '备注',
          align:"center"
        },
        {
          colKey: 'dealOpinion',
          title: '处理意见',
          align:"center"
        },
      ],
      data:[]
    }
  },
  computed:{
    columns(){
      return this.info.type==="yk"?this.columns1:this.columns2
    }
  },
  async mounted() {
    await this.getList()
  },
  methods:{
    onSubmit(){},
    summary(row){
      this.nowRow = row
      this.summaryForm = true
    },
    getList(){
      return this.$api.bzh.opinion.localStandardList({localId:this.info.id}).then(res=>{
        if(this.info.type==="yk"){
          this.data = res.rows
        }else{
          this.data = res.rows.filter(item=> item.summary==="1")
        }

      }).catch(err=>{
        this.$message.error(err)
      })
    },
    onConfirm(){
      this.$emit("closeDialog")
    }
  }
}
</script>

<style scoped>

</style>
